/**
 *====================================================
 * 文件名称: FinanceProcessDetailServiceImpl.java
 * 修订记录：
 * No    日期				作者(操作:具体内容)
 * 1.    2015年10月23日	chenxy(创建:创建文件)
 *====================================================
 * 类描述：(说明未实现或其它不应生成javadoc的内容)
 */
package com.yuexunit.finance.project.service;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;

import com.yuexunit.finance.project.entity.FinanceProcessDetailEntity;
import com.yuexunit.finance.project.entity.lexicon.BusinessTypeEnum;
import com.yuexunit.inject.annotation.Implements;
import com.yuexunit.persist.PersistUtil;
import com.yuexunit.util.DateUtil;

/**
 * @ClassName: FinanceProcessDetailServiceImpl
 * @Description: TODO(这里用一句话描述这个类的作用)
 * @author chenxy
 * @date 2015年10月23日 13:57:30
 */
@Implements(FinanceProcessDetailService.class)
public class FinanceProcessDetailServiceImpl implements FinanceProcessDetailService {

	@Override
	public Long createFinanceProcessDetail(FinanceProcessDetailEntity entity) {
		entity.setCreateDatetime(DateUtil.now());
		PersistUtil.insert(entity);
		return entity.getProcessDetailId();
	}

	@Override
	public void renovateFinanceProcessDetail(FinanceProcessDetailEntity persist) {
		PersistUtil.update(persist);
	}

	@Override
	public List<FinanceProcessDetailEntity> inquireFinanceProcessDetailList(Long processId) {
		DetachedCriteria criteria = DetachedCriteria.forClass(FinanceProcessDetailEntity.class);
		if (processId != null) {
			criteria.add(Restrictions.eq("processId", processId));
		}
		criteria.addOrder(Order.asc("processDetailId"));
		return PersistUtil.get(criteria);
	}

	@Override
	public List<FinanceProcessDetailEntity> inquireFinanceProcessDetailList(Long processId, Long businessId, BusinessTypeEnum businessType) {
		DetachedCriteria criteria = DetachedCriteria.forClass(FinanceProcessDetailEntity.class);
		criteria.add(Restrictions.eq("processId", processId));
		criteria.add(Restrictions.eq("businessId", businessId));
		criteria.add(Restrictions.eq("businessType", businessType));
		criteria.addOrder(Order.asc("processDetailId"));
		return PersistUtil.get(criteria);
	}

}
